<?php
class Info 
{
  //this function get the extension from the file
    function get_extension($file)
    {   
        $file = parse_url($file);
        $file = $file['path'];
        $extension = pathinfo($file);
        $extension = $extension["extension"];
        return $extension;
    }
    
    
    
    //this fubction convent many endings to one name - this name is the filename of the mimetype-icon
    function mime_type($file)
    {
        $extension = $this->get_extension($file);
        
        switch ($extension)
        {
            case "jpg":
            case "jpeg":
            case "JPG":
            case "JPEG":
                return "jpg";
                break;
            case "gif":
            case "giff":
            case "GIF":
            case "GIFF":
                return "gif";
                break;
            case "png":
            case "PNG":
                return "png";
                break;
            case "txt":
            case "TXT":
            case "text":
            case "TEXT":
                return "txt";
                break;
            case "html":
            case "HTML":
            case "htm":
            case "HTM":
            case "dhtml":
            case "DHTML":
            case "shtm":
            case "SHTM":
                return "html";
                break;
            case "pdf":
            case "PDF":
                return "pdf-document";
                break;
            case "deb":
            case "DEB":
                return "deb";
                break;
            case "tex":
            case "TEX":
                return "tex";
                break;
            case "swf":
            case "SWF":
                return "swf";
                break;
            case "tar":
            case "TAR":
                return "tar";
                break;
            case "tgz":
            case "TGZ":
            case "gz":
            case "GZ":
                return "tgz";
                break;
            case "avi":
            case "AVI":
            case "mpg":
            case "MPG":
            case "flv":
            case "FLV":
            case "wmv":
            case "WMV":
            case "mpeg":
            case "MPEG":
            case "mov":
            case "MOV":
            case "m4v":
            case "M4V":
            case "mp4":
            case "MP4":
                return "video";
                break;
            case "zip":
            case "ZIP":
            case "rar":
            case "RAR":
            case "7z":
            case "7Z":
                return "zip";
                break;
            case "rpm":
            case "RPM":
                return "rpm";
                break;
            case "nrg":
            case "NRG":
            case "img":
            case "IMG":
            case "iso":
            case "ISO":
	        return "cdimage";
                break;
	    case "tex":
            case "TEX":
                return "tex";
                break;
	    case "cpp":
            case "CPP":
                return "source_cpp";
                break;
	    case "c":
            case "C":
                return "source_c";
                break;
	    case "h":
            case "H":
                return "source_h";
                break;
	    case "java":
            case "JAVA":
                return "source_java";
                break;
	    case "py":
            case "PY":
                return "source_py";
                break;
	    case "php":
            case "PHP":
	    case "php3":
            case "PHP3":
	    case "php4":
            case "PHP4":
	    case "php5":
            case "PHP5":
	    case "phtml":
            case "PHTML":
                return "source_php";
                break;
	    case "f":
            case "F":
                return "source_f";
                break;
    
        }
    }
    
    
    
    
    
    //this function make links to images
    //if mimetype nown return iconlink
    //if image return link to thumbtailgenerator
    //if unnown return link to an fileicon
    function get_image_adress($file)
        {
        
            $mime_type = $this->mime_type($file);
            clearstatcache();
            
            
            if (($mime_type == "jpg")OR($mime_type == "png")OR($mime_type == "gif"))
            {
            
                return "./includes/icons/img-preview.php?i=$file";
            
            }
            
            
           
            if(!empty($mime_type))
            {
            
                return "./img/kde_crystal_clear/16x16/mimetypes/$mime_type.png";
            
            }
            
            else
            {
                return "./img/kde_crystal_clear/16x16/mimetypes/empty_ascii.png";
            }
        
        }

        
        
        
        
}

?>